package cn.gjculture.shopping.api.dao;

import cn.gjculture.shopping.api.entity.Customer;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CustomerDao {
    @Select("select * from customer where id=#{customerId}")
    Customer queryById(String customerId);

    @Select("select * from customer where openid=#{openid}")
    Customer queryByOpenid(String openid);

    @Select("select * from customer order by updateTime desc")
    List<Customer>  query();

    @Insert("insert into customer(id,nickname,`name`,sex,phone,openid,`level`,insertTime,phoneVerified,phoneVerifiedTime,birthday,`status`," +
            "updateTime,headimgurl,score,country,province,city,`language`,unionid) values(#{id},#{nickname},#{name},#{sex},#{phone},#{openid},#{level}," +
            "#{insertTime},#{phoneVerified},#{phoneVerifiedTime},#{birthday},#{status},#{updateTime},#{headimgurl},#{score},#{country},#{province},#{city},#{language},#{unionid})")
    int insert(Customer customer);

    @Update("update customer set phone=#{phone},phone=#{phoneVerified},phone=#{phoneVerifiedTime} where id=#{id}")
    int setPhoneVerify(Customer customer);
    @Select("select * from customer where `level`>3")
    List<Customer> queryVip();

    @Select("select * from customer where `level`>=2")
    List<Customer> queryRegisterCustomer();

    @Select("select * from customer where phone=#{phone}")
    Customer queryByPhone(String phone);

    @Select("select openid from customer")
    List<Customer> queryAllOpenId();
}
